//
//  AddFriendCell.m
//  BrushFace
//
//  Created by timer_q on 16/1/22.
//  Copyright © 2016年 Zzz. All rights reserved.
//

#import "AddFriendCell.h"
#import <MessageUI/MessageUI.h>
#import "ContactViewModel.h"
#import "NavHelper.h"

@interface AddFriendCell ()

@end

@implementation AddFriendCell

- (void)awakeFromNib {
    // Initialization code
    self.headerImage.layer.cornerRadius = self.headerImage.frame.size.height/2;
    self.headerImage.clipsToBounds = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)statuBtnClick:(id)sender {
    if (self.statu == 0) {
        [self showSMSPicker];
        return;
    }
    if (self.statu == 1) {
        [NavHelper gotoSendFriendVCWithFriendID:self.friendId andSource:@"通讯录匹配"];
    }
    if (self.statu == 3) {
        [NavHelper gotoPassFriendVCWithUserID:self.msgid];
    }
}
#pragma mark - 发短信
- (void)showSMSPicker {
    Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
    if (messageClass != nil) {
        if ([messageClass canSendText]) {
            [self displaySMSComposerSheet];
        }
        else {
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"设备没有短信功能" delegate:self cancelButtonTitle:@"关闭" otherButtonTitles:nil];
            [alert show];
        }
    }
    else {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"iOS版本过低,iOS4.0以上才支持程序内发送短信" delegate:self cancelButtonTitle:@"关闭" otherButtonTitles:nil];
        [alert show];
    }
}
- (void)displaySMSComposerSheet {
    MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
    picker.messageComposeDelegate = self.target;
    NSString *msg = @"我只想任性的借钱给你，送你120元刷脸红包，快来领取吧。http://t.cn/Rb3vvwP";
    picker.body = [[NSString alloc] initWithString:msg];
    NSArray *array = [NSArray arrayWithObjects:self.phone,nil];
    picker.recipients = array;
    [self.target presentViewController:picker animated:YES completion:^{
        
    }];
    
}


@end
